package com.hejie.commentservice.config;

import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.TopicBuilder;

@Configuration
public class KafkaConfig {
    // 评论添加事件主题
    @Bean
    public NewTopic commentAddedTopic() {
        return TopicBuilder.name("comment-added-topic")
                .partitions(3)
                .replicas(1)
                .config("retention.ms", "86400000")
                .build();
    }

    // 评论更新事件主题
    @Bean
    public NewTopic commentUpdatedTopic() {
        return TopicBuilder.name("comment-updated-topic")
                .partitions(3)
                .replicas(1)
                .config("retention.ms", "86400000")
                .build();
    }

    // 评论删除事件主题
    @Bean
    public NewTopic commentDeletedTopic() {
        return TopicBuilder.name("comment-deleted-topic")
                .partitions(3)
                .replicas(1)
                .config("retention.ms", "86400000")
                .build();
    }

    // 视频删除事件主题（用于消费其他服务的事件）
    @Bean
    public NewTopic videoDeletedTopic() {
        return TopicBuilder.name("video-deleted-topic")
                .partitions(3)
                .replicas(1)
                .config("retention.ms", "86400000")
                .build();
    }
}